package com.liuzhilong.infrastructure.basic.decorator;

import com.liuzhilong.infrastructure.basic.decorator.chain.Message;
import com.liuzhilong.infrastructure.basic.decorator.chain.MessageHandlerChain;

public class UseCase {
    /**
     * 这段代码的主要意义是使用Class.forName进行类的初始化操作
     */
    static {
        try {
            Class.forName("com.liuzhilong.infrastructure.basic.decorator.chain.impl.DailyReportEmitter");
        } catch (ClassNotFoundException e) {
        }

        try {
            Class.forName("com.liuzhilong.infrastructure.basic.decorator.chain.impl.OtherDailyReportEmitter");
        } catch (ClassNotFoundException e) {
        }
        try {
            Class.forName("com.liuzhilong.infrastructure.basic.decorator.chain.impl.DefaultReportEmitter");
        } catch (ClassNotFoundException e) {
        }
    }
    public static void main(String[] args) {
        userChain();
    }

    public static final void userChain(){
        MessageHandlerChain.create().exec(Message.create().setMsg("你好请发送每日日报").setFromWxid("OtherDailyReportEmitter"));
        MessageHandlerChain.create().exec(Message.create().setMsg("周天日报").setFromWxid("DailyReportEmitter"));
        MessageHandlerChain.create().exec(Message.create().setMsg("周天日报").setFromWxid("OtherDailyReportEmitter"));
    }
}
